


function gotoURI(uri) {
	document.location.href = uri;
}

function showConfirm(msg,act, id, reload) {
	act_ = act;
	id_ = id;
	reload_ = reload;
	$("#pp_confirm #popup_message").html(msg);
	$("#pp_confirm").css("display", "block");
	$(".backlay").css("display", "block");
	$(".backlay").animate({"opacity":0.6}, 500, function() {});
}
function showAlert(msg) {
	$("#pp_alert #popup_message").html(msg);
	$("#pp_alert").css("display", "block");
	$(".backlay").css("display", "block");
	$(".backlay").animate({"opacity":0.6}, 500, function() {});
}
function hideConfirm() {
	$("#pp_confirm #popup_message").html("");
	$("#pp_confirm").css("display", "none");
	$(".backlay").animate({"opacity":0}, 500, function() {
		$(".backlay").css("display", "none");
	});
}
function hideAlert() {
	$("#pp_alert #popup_message").html("");
	$("#pp_alert").css("display", "none");
	$(".backlay").animate({"opacity":0}, 500, function() {
		$(".backlay").css("display", "none");
	});
}

function autohide(div) {
	$(div).hide("fast");
}
function autoshow(div) {
	$(div).show("fast");
}


function hilightme(objc,clean) {
	$("."+clean).css("font-weight", "normal").removeClass("hilighted");
	$("#"+objc).css("font-weight", "bold").addClass("hilighted");
}

function hilightmenu(menu) {
	$("."+menu).mouseover();
}

function setAction(act,id, reload){
	$("#viewport_patient").html("<div class='wait'></div>");
	setTimeout(function() {
		$.ajax({
			url: "ajax/actions.jsp?action="+act+"&id="+id,
			context: document.body,
			success: function(html){
				$("#viewport_patient").html(html);
				if (reload) reloadList(act);
			}
		});
	},500);
}

function setAction_3D(act,id,idp, reload){
	$("#viewport_patient").html("<div class='wait'></div>");
	setTimeout(function() {
		$.ajax({
			url: "ajax/actions.jsp?action="+act+"&id="+id+"&idp="+idp,
			context: document.body,
			success: function(html){
				$("#viewport_patient").html(html);
				if (reload) reloadList(act);
			}
		});
	},500);
}

function warn(act, id, name, reload) {
	if (act=="delete") txt = "supprimmer";
	else if (act == "pack") txt = "archiver";
	else if (act == "drop_user") txt = "supprimmer";
	
	if (act == "drop_user" && id==0) {
		showAlert("Pour des raisons de sécurité, vous ne pouvez pas supprimer cet utilisateur");
	}
	else {
		showConfirm("Voulez vous "+txt+" "+name+" ?",act, id, reload);
	}
}

function alert2(msg) {
	showAlert(msg);
}

function reloadList(act) {
	$("#viewlist").html("<div class='wait'></div>");
	setTimeout(function() {
		$.ajax({
			url: "ajax/actions.jsp?action=refresh&foract="+act,
			context: document.body,
			success: function(html){
				$("#viewlist").html(html);
			}
		});
	},500);
}
